<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Mongoose ODM v5.6.0</title><link href="//fonts.googleapis.com/css?family=Anonymous+Pro:400,700|Droid+Sans+Mono|Open+Sans:400,700|Linden+Hill|Quattrocento:400,700|News+Cycle:400,700|Antic+Slab|Cabin+Condensed:400,700" rel="stylesheet" type="text/css"><link href="docs/css/default.css" rel="stylesheet"><link href="docs/css/style.css" rel="stylesheet"><link href="/docs/css/github.css" rel="stylesheet"><style>code {
  font-size: 1em;
}

.sponsor {
  margin-bottom: 40px;
  font-size: 0.66em;
  color: #666;
  text-decoration: none;
}

.sponsors {
  margin-bottom: 40px;
}

.sponsors a {
  text-decoration: none;
}

.carbonad{
  margin-top:0!important;
  margin-bottom:-3rem!important
}

#carbonads {
  position:fixed;
  right: 0px;
  bottom: 0px;
  display:block;
  width:200px;
  padding:15px 15px 15px 160px;
  overflow:hidden;
  font-size:13px;
  line-height:1.4;
  text-align:left;
  background-color: #fafafa;
}

@media (max-width: 1160px) {
  #carbonads {
    display: none !important;
  }
}

#carbonads a{color:#333;text-decoration:none}

.carbon-img{float:left;margin-left:-145px}

.carbon-poweredby{display:block;color:#777!important}

img.sponsor {
  margin-right: 10px;
  border: 1px dotted #dfdfdf;
  height: 100px;
}
</style></head><body><a id="forkbanner" href="http://github.com/learnboost/mongoose"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a><div class="homepage" id="wrap"><div id="header"><h1><a href="https://github.com/Automattic/mongoose" target="blank"><div class="mongoose">Mongoose</div></a></h1></div><div class="tagline"><p>Elegant <a href="https://www.mongodb.com/">MongoDB</a> object modeling for
<a href="https://nodejs.org/en/">Node.js</a></p>
</div><div id="links"><ul><li><a href="docs/guide.html">Read the Docs</a></li><li><a href="http://plugins.mongoosejs.io">Discover Plugins</a></li></ul></div><div id="follow"><ul><li><iframe class="github-btn" src="//ghbtns.com/github-btn.html?user=Automattic&amp;repo=mongoose&amp;type=watch&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe></li><li id="version"><span>Version 5.6.0</span></li><li><iframe class="github-btn" src="//ghbtns.com/github-btn.html?user=Automattic&amp;repo=mongoose&amp;type=fork&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="100px" height="20px"></iframe></li></ul></div><div id="inner"><div id="what"><p class="what">Let's face it,&nbsp;<strong>writing MongoDB validation, casting and business logic boilerplate is a drag</strong>. That's why we wrote Mongoose.</p></div><pre><code class="language-javascript"><span class="hljs-keyword">const</span> mongoose = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mongoose'</span>);
mongoose.connect(<span class="hljs-string">'mongodb://localhost:27017/test'</span>, {useNewUrlParser: <span class="hljs-literal">true</span>});

<span class="hljs-keyword">const</span> Cat = mongoose.model(<span class="hljs-string">'Cat'</span>, { name: <span class="hljs-built_in">String</span> });

<span class="hljs-keyword">const</span> kitty = <span class="hljs-keyword">new</span> Cat({ name: <span class="hljs-string">'Zildjian'</span> });
kitty.save().then(() =&gt; <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'meow'</span>));</code></pre>
<p>Mongoose provides a straight-forward, schema-based solution to model
your application data. It includes built-in type casting, validation,
query building, business logic hooks and more, out of the box.</p>
<div id="tidelift"><a id="tidelift-button" href="https://tidelift.com/subscription/pkg/npm-mongoose?utm_source=npm-mongoose&utm_medium=website">
  <img src="/docs/images/tidelift.svg" />
  <span>Get Professionally Supported Mongoose</span>
</a>
</div><div class="carbon-ad"><script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1673&serve=C6AILKT&placement=mongoosejscom" id="_carbonads_js"></script></div><h2 id="getting-started">Getting Started</h2>
<ul>
<li><a href="/docs/index.html">quick start guide</a></li>
</ul>
<h2 id="support">Support</h2>
<ul>
<li><a href="http://stackoverflow.com/questions/tagged/mongoose">Stack Overflow</a></li>
<li><a href="https://github.com/Automattic/mongoose/issues">GitHub Issues</a></li>
<li><a href="https://gitter.im/Automattic/mongoose">Gitter Chat</a></li>
<li><a href="http://www.mongodb.org/about/support/">MongoDB Support</a></li>
</ul>
<h2 id="news">News</h2>
<ul>
<li><a href="https://twitter.com/mongoosejs">Twitter</a></li>
</ul>
<h2 id="changelog">Changelog</h2>
<ul>
<li><a href="https://github.com/Automattic/mongoose/blob/master/History.md">Changelog</a></li>
</ul>
<h2 id="sponsors">Sponsors</h2>
<div class="sponsors">
  <div>
    <a href="https://mixmax.com">
      <img class="sponsor" src="/docs/images/mixmax.png" alt="MixMax.com">
    </a>
    <a href="https://localizejs.com/">
      <img class="sponsor" src="//ww1.prweb.com/prfiles/2015/10/28/13050459/localize-logo-black.png">
    </a>
    <a href="https://www.codefirst.co.uk/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2Fdde88120-e914-11e8-a662-278259d35390.png&height=100">
    </a>
    <a href="https://www.vpsserver.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Fvpsserver.com&height=100">
    </a>
    <a href="https://icons8.com/">
      <img class="sponsor" src="https://s3.amazonaws.com/codebarbarian-images/Icons8+Logo+500px.png" style="height:100px">
    </a>
    <a href="https://topvet.net/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Ftopvet.net&height=100" style="height:100px">
    </a>
    <a href="https://www.dontpayfull.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F84c4ba80-1955-11e8-8343-278614155b3e.png&height=100" style="height:100px">
    </a>
    <a href="https://marcus-hiles.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fwww.gravatar.com%2Favatar%2F18234f5f0ed822f7b879f50b285c47eb%3Fdefault%3D404&height=100" style="height:100px">
    </a>
    <a href="https://craftresumes.com/professional-resume-writer/">
      <img class="sponsor" alt="Professional resume writer" src="https://s3.amazonaws.com/codebarbarian-images/craftresumes.png">
    </a>
    <a href="https://domainwheel.com/">
      <img class="sponsor" src="https://s25990.pcdn.co/wp-content/themes/namegenerator/img/logo_dw.jpg" style="height:100px">
    </a>
    <a href="https://uiuxagencies.top/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F62223ab0-f4f7-11e8-919f-53f2ea21a967.png&height=100" style="height:100px">
    </a>
    <a href="https://www.promocodewatch.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2Fbd0053f0-4f64-11e9-8022-91853c58485e.png&height=100" style="height:100px">
    </a>
    <a href="https://www.vpnranks.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Fvpnranks.com&height=100" style="height:100px">
    </a>
    <a href="https://www.bestvpn.co/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Fwww.bestvpn.co&height=100" style="height:100px">
    </a>
    <a href="https://blokt.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Flogo.clearbit.com%2Fblokt.com&height=100" style="height:100px">
    </a>
    <a href="https://paperleaf.ca/">
      <img class="sponsor" alt="Essay writing service in Canada" src="https://s3.amazonaws.com/codebarbarian-images/paperleaf.jpg">
    </a>
    <a href="https://usave.co.uk/utilities/broadband/">
      <img class="sponsor" title="Compare broadband deals with usave" src="https://usave.co.uk/img/brand/brand-logo.png" style="height:100px">
    </a>
    <a href="http://clay.global/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F09d57c90-637c-11e7-9ed2-bfa12b0351e8.jpg&height=100" style="height: 100px">
    </a>
    <a href="https://tekhattan.com/">
      <img class="sponsor" src="https://images.opencollective.com/proxy/images?src=https%3A%2F%2Fopencollective-production.s3-us-west-1.amazonaws.com%2F31835450-5a98-11e9-adb1-e17fccd4c65e.png&height=80" style="height:80px">
    </a>
  </div>
</div>

<div class="sponsor">
  Sponsor <a href="https://opencollective.com/mongoose">Mongoose on OpenCollective</a>
  to get your company's logo above!
</div>
</div></div><p id="footer">Licensed under MIT. Copyright 2011 <a href="http://learnboost.com">LearnBoost</a>.</p><script>document.body.className = 'load';</script><script type="text/javascript">var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://g0a3nbw0xa.execute-api.us-east-1.amazonaws.com/prod/track', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {};
xhr.send(JSON.stringify({
  path: window.location.pathname,
  hostname: window.location.hostname,
  hash: window.location.hash
}));</script></body></html>